import 'package:base_flutter/base_flutter.dart';
import 'package:ls_work/operational_statistics/operational_statistics_api.dart';
import 'package:ls_work/operational_statistics/response/bed_statistics_data.dart';
import 'package:ls_work/operational_statistics/response/month_activity_data.dart';
import 'package:ls_work/operational_statistics/response/month_into_data.dart';
import 'package:ls_work/operational_statistics/response/month_into_out_data.dart';
import 'package:ls_work/operational_statistics/response/today_into_data.dart';
class OperationalStatisticsModel extends BaseMvvmModel{
  @override
  void onCleared() {
    // TODO: implement onCleared
  }

  ///入住率统计
  Future<BedStatisticsData> bedStatistics() async {
    var data = await HttpGo.instance.postData(OperationalStatisticsApi.roomStatistics);
    if("0"==data['code']){
      return BedStatisticsData.fromJson(data['data']);
    }else{
      throw data['msg'];
    }
  }


  ///月入住退出统计
  Future<MonthIntoData> monthInto() async {
    var data = await HttpGo.instance.postData(OperationalStatisticsApi.monthInto);
    if("0"==data['code']){
      return MonthIntoData.fromJson(data['data']);
    }else{
      throw data['msg'];
    }
  }

  ///月入住统计chart
  Future<MonthIntoOutData> monthInOutChart(String yearMonthStart,String yearMonthEnd) async {
    var map = {
      "yearMonthStart":yearMonthStart,
      "yearMonthEnd":yearMonthEnd,
    };
    var data = await HttpGo.instance.postData(OperationalStatisticsApi.monthChart,data: map,options: Options(contentType: Headers.formUrlEncodedContentType));
    if("0"==data['code']){
      return MonthIntoOutData.fromJson(data['data']);
    }else{
      throw data['msg'];
    }
  }

  ///今日入住、退住
  Future<TodayIntoData> todayInto() async {
    var data = await HttpGo.instance.postData(OperationalStatisticsApi.todayInto);
    if("0"==data['code']){
      return TodayIntoData.fromJson(data['data']);
    }else{
      throw data['msg'];
    }
  }

  ///活动统计月份
  Future<MonthActivityData> monthActivity(String yearMonthStart,String yearMonthEnd) async {
    var map = {
      "yearMonthStart":yearMonthStart,
      "yearMonthEnd":yearMonthEnd,
    };
    var data = await HttpGo.instance.postData(OperationalStatisticsApi.monthActivity,data: map,options: Options(contentType: Headers.formUrlEncodedContentType));
    if("0"==data['code']){
      return MonthActivityData.fromJson(data['data']);
    }else{
      throw data['msg'];
    }
  }

  Future<Map> monthServiceStatistics() async {
    var data = await HttpGo.instance.postData(OperationalStatisticsApi.monthServiceData);
    if("0"==data['code']){
      return data['data'];
    }else{
      throw data['msg'];
    }
  }
}